use smol::stream::StreamExt;
use std::iter::FromIterator;
use std::time::Duration;

fn main() {
    smol::block_on(sel());
}

async fn sel() {
    println!("Hello, world!");

    let mut tasks = Vec::new();
    for i in 0..5 {
        tasks.push(smol::spawn(async move {
            smol::Timer::after(Duration::from_secs(2)).await;
            i
        }));
    }

    let mut s = util::stream_vec::StreamVec::from_iter(tasks);
    while let Some(i) = s.next().await {
        println!("{}", i)
    }

    // for v in select_all(Vec::<i32>::new(), tasks).await {
    //     println!("{}", v)
    // }
}
